import en from '../i18n/language/en'
import zh from '../i18n/language/zh'
import components from 'openatc-components'

function getMessageByCode (code, langusge) {
  let res = 'error'
  let message = zh.edge.message
  let componentsMessage = components.language.zh.openatccomponents.message
  if (langusge) {
    if (langusge === 'en') {
      message = en.edge.message
      componentsMessage = components.language.en.openatccomponents.message
    }
    message = {...message, ...componentsMessage}
    if (code) {
      if (message[code]) {
        res = message[code]
      } else {
        res = message.errorcode + ' ' + code
      }
    }
  }
  return res
}

export {
  getMessageByCode
}
